package round1B.question2;

import java.util.Scanner;

public class Bate1
{
	private static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args)
	{
		int round = sc.nextInt();
		for(int i=1; i<=round; i++)
			System.out.println("Case #" + i + ": " + next());
	}

	private static long next()
	{
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		
		long m = 0;
		m += k * ((a-k) + (b-k) + k);
		
		int al = Integer.toBinaryString(a).length();
		int bl = Integer.toBinaryString(b).length();
		int kl = Integer.toBinaryString(k).length();
		
		int mi = al > bl? bl - kl : al - kl;
		long mo = 0;
		
		if(mi > 0)
		{
			if(mi % 2 == 0)
			{
				for(int i=(mi-1)/2; i>=0; i--)
				{
					mo += gc(i, mi);
				}
				mo *= 2;
				mo += gc(mi / 2, mi);
			}
			else
			{
				for(int i=mi/2; i>=0; i--)
				{
					mo += gc(i, mi);
				}
				mo *= 2;
			}
		}
		
		mi = Math.abs(al-bl);
		long mo2 = 0;
		if(mi > 0)
		{
			if(mi % 2 == 0)
			{
				for(int i=(mi-1)/2; i>=0; i--)
				{
					mo2 += gc(i, mi);
				}
				mo2 *= 2;
				mo2 += gc(mi / 2, mi);
			}
			else
			{
				for(int i=mi/2; i>=0; i--)
				{
					mo2 += gc(i, mi);
				}
				mo2 *= 2;
			}
		}
		
		if(mo2 == 0)
		{
			return m + mo;
		}
		else
		{
			return m + mo * mo2;
		}
	}

	private static long gc(int i, int mi)
	{
		int r = 1;
		
		while(i > 0)
		{
			r = r * mi-- / i--;
		}
		
		return r;
	}
}
